package com.handu.luna.core.domain.order;

import javax.persistence.Entity;
import javax.persistence.Transient;

import com.handu.luna.core.domain.BasePersistentDomain;
import com.handu.luna.core.domain.goods.Goods;

@Entity
public class OrderDetail extends BasePersistentDomain<OrderDetailRepository>{
	
	private long count;
	
	private long goodsId;
	
	@Transient
	private Goods goods;
	
	private String orderNumber;//子订单单号
	
	@Transient
	private OrderInfo order;//子订单

	public long getCount() {
		return count;
	}

	public void setCount(long count) {
		this.count = count;
	}

	public long getGoodsId() {
		return goodsId;
	}

	public void setGoodsId(long goodsId) {
		this.goodsId = goodsId;
	}

	public Goods getGoods() {
		if(this.goodsId != 0 && goods == null){
			goods = context.getGoodsRepository().findOne(this.goodsId);
		}
		return goods;
	}

	public void setGoods(Goods goods) {
		this.goods = goods;
	}

	public String getOrderNumber() {
		return orderNumber;
	}

	public void setOrderNumber(String orderNumber) {
		this.orderNumber = orderNumber;
	}

	public OrderInfo getOrder() {
		return order;
	}

	public void setOrder(OrderInfo order) {
		this.order = order;
	}

	public OrderDetail(long count, long goodsId, String orderNumber) {
		super();
		this.count = count;
		this.goodsId = goodsId;
		this.orderNumber = orderNumber;
	}

	public OrderDetail() {
		super();
	}
}
